package net.yambal.air.mobile.bkmt
{
	import flash.data.SQLResult;
	import flash.filesystem.File;
	
	import jp.cre8system.framework.airrecord.db.ARDatabase;

	public class BKMTImageList
	{
		
		private static var _instance:BKMTImageList;
		private var _db:ARDatabase = null;
		private static const _ddl:Array = [
			"CREATE TABLE IF NOT EXISTS images (" +
			"            id           INTEGER PRIMARY KEY," +
			"            path         TEXT" +
			")"
		]
		
		public function BKMTImageList()
		{
			// db
			_db = ARDatabase.instance;
			_db.add("bkmt", "1234", "ImageList", _ddl);
			_db.connect();
		}
		
		public static function getInstance():BKMTImageList {
			if(_instance == null){
				_instance = new BKMTImageList();
			}
			return _instance;
		}
		
		public function insert(path:String):Number{
			var image:BKMTImage = new BKMTImage();
			var result:SQLResult = image.insert({path:path});
			var bookID:Number = result.lastInsertRowID;
			
			return bookID;
		}
		
		public function getAll():Array{
			var image:BKMTImage = new BKMTImage();
			return image.find();
		}
	}
}